﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp.Study.Test
{
    public static class 序号
    {
        public static void Go()
        {
            var arr = new int[] { 1, 2, 3, 4, 5 };
            var i = arr[^2];
            var newarr = arr[1..3];
            foreach (int j in 1..20)
            {
                Console.WriteLine(j);
            }
        }


        public static IEnumerator<int> GetEnumerator(this Range range)
        {
            if (range.Start.IsFromEnd || range.End.IsFromEnd)
                throw new ArgumentException(nameof(Range));
            for (int i = range.Start.Value; i <= range.End.Value; i++)
            {
                yield return i;
            }
        }
    }
}
